package com.xiangxiangjd.kj.papersstar.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xiangxiangjd.kj.papersstar.bean.User;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @author jinbin
 * @date 2018-07-08 20:44
 */

public interface UserMapper extends BaseMapper<User> {
    User findByUsername(@Param("username") String username);
    User findUserById(@Param("id") String id);
    User findUserByPhone(@Param("phone") String phone);
    void UpdateUserToken(User user);

    @Update("<script>" +
            " update u_user" +
            " <set>" +
            " <if test='user.token != null'>" +
            "  token = #{user.token}," +
            " </if>" +
            " <if test='user.updateTime != null'>" +
            "  update_time=#{user.updateTime}," +
            " </if>" +
            " </set>" +
            " where id =" +
            " #{user.id}" +
            " </script>")
    int layout(@Param("user") User user);


    /** 分页查询UUser
     * @param map.page  页码
     * @param map.limit  查几条
     * @param map.uUser  前端传进的参数
     * @return 返回统一分页信息
     */
    List<User> selectMyPage(@Param("map") Map map);
    Integer countMyPage(@Param("map") Map map);

}
